import Vue from 'vue'
import VueRouter from 'vue-router'

const Select = () => import("../views/select");
const Chart = () => import("../views/chart");
const Cuowu = () => import("../views/cuowu");

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

Vue.use(VueRouter)

const routes = [
  {
    path: "/",
    redirect: {
      name: 'select'
    },
    meta: {
      title: '图表筛选'
    },
    component: Select
  },
  {
    path: "/select",
    name: "select",
    meta: { keepAlive: true },
    component: Select
  },
  {
    path: "/chart",
    name: "chart",
    meta: { keepAlive: false },
    component: Chart
  },
  {
    path: "*",
    name: "404",
    component: Cuowu
  }
]

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes
})

export default router
